﻿[[title="岗位管理",pagesize="20",orderby="createTime asc",condition=""]]
<script type="text/javascript" language="javascript">
    //<用户 角色 授权>
    var userRoles = new Array();
    var userNo = wmsCommon.getEncodeQueryStr('userNo');
    var userName = wmsCommon.getEncodeQueryStr('userName')
    window.onload = function () {
        InitUserRole();
    }
    //初始化权限
    function InitUserRole() {
        var model = "userRoleInfo";
        var getUserRoles = "sys(#RoleManager.InitUserRole(" + userNo + "," + model + "))";
        var user_Roles = wmsCommon.execCommand(getUserRoles);
        if (user_Roles != "") {
            userRoles = eval(user_Roles);
            for (var i = 0; i < userRoles.length; i++) {
                try {
                    document.getElementById(userRoles[i].roleCode.toString()).checked = true;
                }
                catch (e) {

                }
            }
        }

    }
    //保存用户 角色权限;
    function saveUserRole() {
        var changechckArr = getChangeChecked("role_chk");
        var userNo = wmsCommon.getEncodeQueryStr('userNo');
        var model = "userRoleInfo"; //wmsCommon.getQueryValue('model');
        var jsUserRoleStr = wmsCommon.objToJsonStr(changechckArr);
        jsUserRoleStr = jsUserRoleStr.replace(/"/g, "\\\"");

        var saveExpr = "sys(#RoleManager.SaveUserRolePermission(" + userNo + ",quote{" + jsUserRoleStr + "}," + model + "))";
        var result = wmsCommon.execCommand(saveExpr);
        if (result != undefined) {
        if(confirm("保存成功,是否确认关闭窗口?"))
            top.window.close();
        }
        else {
            if (confirm("保存失败,请与管理员联系!!,是否关闭窗口?")) {
                top.window.close();
            }
        }
        //window.parent.close();

    }
    //获取变化点权限
    function getChangeChecked(name) {

        var checkArr = new Array();
        var CheckList = document.getElementsByName(name);
        for (var i = 0; i < CheckList.length; i++) {
            var checdobj = new Object();
            if (CheckList[i].checked) { //add new qx
                checdobj.value = CheckList[i].value;
                checdobj.title = CheckList[i].title;
                checdobj.check = "true"; // 
                checkArr.push(checdobj);
                var nowSelectCheck = new Object();
                nowSelectCheck.userNo = userNo;
                nowSelectCheck.roleCode = CheckList[i].value;
                userRoles.push(nowSelectCheck);
            }
            else {
                for (var k = 0; k < userRoles.length; k++) {
                    if (userRoles[k].roleCode.toString() == CheckList[i].value) {
                        checdobj.value = CheckList[i].value;
                        checdobj.title = CheckList[i].title;
                        checdobj.check = "false"; // delete qx
                        checkArr.push(checdobj);
                    }
                }
            }

        }
        return checkArr;
    }
    function changeWindowSize() {
        wmsCommon.setListDivStyle("listDiv", 1);
    }

    $(function () {
        wmsCommon.setListDivStyle("listDiv", 1);
    });
</script>
<div class="ContentArea">
    <table cellspacing="0" cellpadding="0" class="TblSearchPanel">
        <tr>
            <td class="TblSearchPanel_01">
            </td>
            <td class="TblSearchPanel_02">
                <div class="DivSearchTitle" style="float: left;">
                    查询条件</div>
                <img alt="点此隐藏或显示搜索区域" id="Image2" src="res/images/display.gif" class="ImgSearch"
                    onclick="wmsCommon.searchContentCtr()" />
            </td>
            <td class="TblSearchPanel_03">
            </td>
        </tr>
        <tr>
            <td class="TblSearchPanel_04">
            </td>
            <td>
                <!-- search content start -->
                <table id="tblSearch" class="SearchTable">
                    <tr>
                        <td style="text-align: left; width: 100%;">
                            <table style="width: auto;">
                                <tr>
                                    <td class="tdright">
                                        $roleInfo.Columns.get_Item("roleName").DisplayName()：
                                    </td>
                                    <td class="tdleft">
                                        $roleInfo.Columns.get_Item("roleName").RenderAsQuery()
                                    </td>
                                    <td class="tdright">
                                        $roleInfo.Columns.get_Item("roleCode").DisplayName()：
                                    </td>
                                    <td class="tdleft">
                                        $roleInfo.Columns.get_Item("roleCode").RenderAsQuery()
                                    </td>

                                </tr>
                            </table>
                        </td>
                        <td style="vertical-align: bottom;">
                            <div style="width: 100%">
                                $render.RenderButton()
                            </div>
                        </td>
                    </tr>
                </table>
                <!-- search content end-->
            </td>
            <td class="TblSearchPanel_06">
            </td>
        </tr>
        <tr>
            <td class="TblSearchPanel_07">
            </td>
            <td class="TblSearchPanel_08">
            </td>
            <td class="TblSearchPanel_09">
            </td>
        </tr>
    </table>
    <!--list content start-->
     <div id="listDiv" class="listDivStyle">
     <table id="contenttb" cellpadding="0" cellspacing="0" class="tblList">
        <tr class="FixedTitleRow">
            <th>
                <span style="cursor: hand" onclick="wmsCommon.checkedAll('contenttb')">选择</span>
            </th>
            <th style="width: 30px">
                $roleInfo.Columns.get_Item("ROWNUM").Render()
            </th>
            <th>
                $roleInfo.Columns.get_Item("roleName").Render()
            </th>
            <th>
                $roleInfo.Columns.get_Item("roleCode").Render()
            </th>         
            <th>
                $roleInfo.Columns.get_Item("createTime").Render()
            </th>
        </tr>
        #foreach($row in $roleInfo.Rows)
        <tr keyvalue="$row.RenderKeyValue()">
            <td>
                <input style="cursor: hand; border: 0" name="role_chk" id='$row.get_Item("roleCode").Render()' value='$row.get_Item("roleCode").Render()' title='$row.get_Item("roleName").Render()' type="checkbox" />
            </td>
            <td style="width: 30px">
                $row.get_Item("ROWNUM").Render()
            </td>
            <td>
                $row.get_Item("roleName").Render()
            </td>
            <td>
                $row.get_Item("roleCode").Render()
            </td>
            <td style="text-align:center;">
                $row.get_Item("createTime").Render("format=yyyy-MM-dd HH:mm;")
            </td>
        </tr>
        #end
    </table>
    </div>
    <div>
       $render.RenderPaging($roleInfo)
    </div>
    <div style="height: 20px; background-color: rgb(233, 231, 215);">
    $render.RenderButton("text=保存授权; displayType=button; actionType=modify; clientMethod=saveUserRole(); ")
    </div>
</div>
<!-- list content end-->
